package com.itlong.cloud.operate.service.impl;

import com.itlong.cloud.POJO.DTO.operate.OperateRobotLogGetPageDTO;
import com.itlong.cloud.POJO.VO.operate.OperateRobotLogGetPageVO;
import com.itlong.cloud.operate.dao.IOperateRobotLogDao;
import com.itlong.cloud.operate.service.IOperateRobotLogService;
import com.itlong.cloud.utils.data.handler.SqlUtil;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      运营-机器人操作日志管理服务层处理接口实现类
 * </desc>
 *
 * @createDate 2018/10/12
 */
@Service
public class OperateRobotLogServiceImpl implements IOperateRobotLogService {

    @Autowired
    private IOperateRobotLogDao iOperateRobotLogDao;

    /**
     * <desc>
     *      分页查询机器人操作日志
     * </desc>
     *
     * @param operateRobotLogGetPageDTO 查询参数
     * @return 查询结果
     * @author wangzhi
     * @createDate 2018/10/12
     */
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public Page<OperateRobotLogGetPageVO> getRobotLogByPage(OperateRobotLogGetPageDTO operateRobotLogGetPageDTO) throws Exception {
        Map<String,Object> params = SqlUtil.convertBeanToMapParams(operateRobotLogGetPageDTO);
        Page<OperateRobotLogGetPageVO> page = new Page<>();
        page.getPage().setPageSize(operateRobotLogGetPageDTO.getPageSize());
        page.getPage().setCurrentPage(operateRobotLogGetPageDTO.getCurrentPage());
        params.put("startSlip", page.getPage().getStartSlip());
        params.put("pageSize", page.getPage().getPageSize());
        List<OperateRobotLogGetPageVO> operateRobotLogGetPageVOS = iOperateRobotLogDao.getRobotLogByPage(params);
        page.setRows(operateRobotLogGetPageVOS,iOperateRobotLogDao.getRobotLogRecordCount(params));
        return page;
    }
}
